package self.security.entity;


import org.springframework.security.core.GrantedAuthority;
import self.pojo.User;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者: liYu
 * 题目: SecurityUser
 * 项目名字 CD-Java-2307-springboot-parent
 * 描述: 这个就是查询数据库返回的这个对象
 */
public class  SecurityUser extends org.springframework.security.core.userdetails.User {

    //这个就是数据库的用户的信息
    private User user;

    public SecurityUser() {
        super("username", "password", new ArrayList<GrantedAuthority>());
    }

    @Override
    public String getUsername() {
        return user.getUserName();
    }


    @Override
    public String getPassword() {
        return user.getPassword();
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public User getUser() {
        return user;
    }

    //维护的这个角色和权限的集合
    private List<String> roleAndPermList;

    public List<String> getRoleAndPermList() {
        return roleAndPermList;
    }

    public void setRoleAndPermList(List<String> roleAndPermList) {
        this.roleAndPermList = roleAndPermList;
    }


}
